import http.cookiejar, urllib.request

# filename = 'cookies.txt'
# cookie = http.cookiejar.MozillaCookieJar(filename)

filename = 'cookies_format_LWP.txt'
cookie = http.cookiejar.LWPCookieJar(filename)

handler = urllib.request.HTTPCookieProcessor(cookie)

opener = urllib.request.build_opener(handler)

response = opener.open('http://www.baidu.com')

cookie.save(ignore_discard = True,ignore_expires = True)